package com.study.feign.hystrix;

import com.alibaba.fastjson.JSON;
import com.study.account.AddressInfo;
import com.study.common.TableId;
import com.study.feign.AddresClient;
import com.study.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collections;

/**
 * 账号服务熔断兜底策略
 */
@Slf4j
@Component
public class AddressClientHystrix implements AddresClient {
    @Override
    public CommonResponse<AddressInfo> getAddressInfoByTableId(TableId tableId) {

        log.error("account client feign request error: [{}]",
                JSON.toJSONString(tableId));

        return new CommonResponse<>(
          -1,
          "account client feign request error",
          new AddressInfo(-1L, Collections.emptyList())
        );
    }
}
